'''This module supplies some 'extra' oper functions, like /sacycle and 
/samove. Please use responsibly.'''
############################################################################
#    Copyright (C) 2006 by Robert Small                                    #
#    SmallR2002@Gmail.com                                                  #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################

__module_name__        = "bcoperfunctions"
__module_version__     = "0.0.1"
__module_description__ = "This module supplies some 'extra' oper functions, like /sacycle and /samove"

import xchat

################################################################################################
################################################################################################
#                                       OPER/SA FUCTIONS                                       #
################################################################################################

#  What can I say? The SANick function changes someone's nick, the SACycle cycles them in a
# channel, the SAMove function moves them to another channel. Simple stuff, few updates ever
# hit this file.
#  Only changes are SACycle having /sacycle user [#channel] instead of channel being needed,
# Added similar with /samove, if one parameter is given it moves them from this channel to the
# other.

def sanick_replace(word, word_eol, userdata): #IGNORE:W0613
    '''
    Change a nick.
    @param word: all the data you need to work with, chopped up into small parts.
    @type word: string
    @param word_eol: all the data you need to work with, chopped from wherever you're starting from.
    @type word_eol: string
    @param userdata: custom object to pass back.
    @type userdata: object
    '''
    xchat.command('msg operserv svsnick ' + word[1] + " " + word[2])
    return xchat.EAT_XCHAT
#End of sub

def sacycle_replace(word, word_eol, userdata): #IGNORE:W0613
    '''
    Cycle a user.
    @param word: all the data you need to work with, chopped up into small parts.
    @type word: string
    @param word_eol: all the data you need to work with, chopped from wherever you're starting from.
    @type word_eol: string
    @param userdata: custom object to pass back.
    @type userdata: object
    '''
    if (len(word) == 3):
        temproom = word[2]
    else:
        temproom = xchat.get_info('channel')
    
    xchat.command('sapart ' + word[1] + " " + temproom)
    xchat.command('sajoin ' + word[1] + " " + temproom)
    return xchat.EAT_XCHAT
#End of sub

def samove_replace(word, word_eol, userdata): #IGNORE:W0613
    '''
    Move a user.
    @param word: all the data you need to work with, chopped up into small parts.
    @type word: string
    @param word_eol: all the data you need to work with, chopped from wherever you're starting from.
    @type word_eol: string
    @param userdata: custom object to pass back.
    @type userdata: object
    '''
    if (len(word) == 3):
        firstroom = xchat.get_info('channel')
        secondroom = word[2]
    else:
        firstroom = word[2]
        secondroom = word[3]
    
    xchat.command('sapart ' + word[1] + " " + firstroom)
    xchat.command('sajoin ' + word[1] + " " + secondroom)
    return xchat.EAT_XCHAT
#End of sub